﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DoAnOOP.DataAccessLayer;
using System.Data;
using System.Windows.Forms;

namespace DoAnOOP.BussinessLayer
{
    class clsQLSV
    {
        #region Biến cục bộ
        clsConnect _myConnect = new clsConnect();

        public string mssv { get; set; }
        public string Ho { get; set; }
        public string Ten { get; set; }
        public string GioiTinh { get; set; }
        public string NgaySinh { get; set; }
        public string NoiSinh { get; set; }
        public string MaKhoa { get; set; }
        public string NgayVaoDoan { get; set; }
        public string Email { get; set; }
        #endregion

        #region Hàm 
        public DataTable LayThongTinSinhVien(string khoa)
        {
            string sql = "SELECT MSSV, HO, TEN, GIOITINH, NGAYSINH, NOISINH, MAKHOA, NGAYVAODOAN, EMAIL FROM LYLICH";
            sql += khoa;
            return _myConnect.GetDataTable(sql);
        }

        public void ThemThongTinSinhVien()
        {
            string sql = "INSERT INTO LYLICH VALUES ('" + mssv + "','" + Ho + "','" + Ten + "','" + 
                GioiTinh + "','" + NgaySinh + "','" + NoiSinh + "','" + MaKhoa + "','" + 
                NgayVaoDoan + "','" + Email + "')";
            _myConnect.ExecuteNonquery(sql);

        }
        public void UpdateThongTinSinhVien()
        {
            string sql = "UPDATE LYLICH SET Ho = '" + Ho + "', Ten = '" + Ten + "', GioiTinh = '" + GioiTinh + "', Ngaysinh = '" +
                NgaySinh + "', Noisinh = '" + NoiSinh + "', MaKhoa = '" + MaKhoa + "', NgayVaoDoan = '" + 
                NgayVaoDoan + "', Email = '" + Email + "' WHERE MSSV = '" + mssv+ "'";
            _myConnect.ExecuteNonquery(sql);
        }
        public void DeleteThongTinSinhVien()
        {
            string sql = "DELETE FROM LYLICH WHERE MSSV = '"+mssv+"'"; 
            _myConnect.ExecuteNonquery(sql);
        }
        #endregion
    }
}
